<!DOCTYPE html>
<html lang="zh">

<head>
    <title></title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="https://cdn.staticfile.net/vue/2.7.8/vue.js"></script>
    <link href="../css/style.css" rel="stylesheet">
</head>

<body>
<div id="app">
    <p>{{message}}</p>
    <p>{{message | toUpper }}</p>

    <p>{{num}}</p>
    <p>{{num | topercentage}}</p>
</div>
<script>
    const vm = new Vue({
        el: '#app',
        data: {
            message: 'this is an Apple',
            num: 0.3
        },
        filters: {
            toUpper: function (val) {
                console.log(1)
                return val.toUpperCase();
            },
            topercentage: function (val) {
                console.log(2)
                return val * 100 + '%'
            }
        }
    });
</script>
</body>
</html>